#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int maxArea(vector<int>& height) {
        int left = 0;
        int right = height.size() - 1;
        int Max = 0;
        while (left < right)
        {
            int val = min(height[left], height[right]) * (right - left);
            Max = max(Max, val);
            if (height[left] == min(height[left], height[right]))
                left++;
            else
                right--;
        }

        return Max;
    }
};